import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    list:JSON.parse(localStorage.getItem('list')|| '[]') ,
    login:JSON.parse(localStorage.getItem('user')) || '[]' ,
    showrecord:JSON.parse(localStorage.getItem('showRecord')|| '[]') ,
  },
  mutations: {
    userLogin(state, value){
      state.login = value.user
      localStorage.setItem('user',JSON.stringify(state.login))
    },
    
    userLogins(state, value){
      console.log(value)
      state.login = value
      localStorage.setItem('user',JSON.stringify(state.login))
       console.log(state.login)
    },
    showList(state,value){
      state.list = value
      localStorage.setItem('list',JSON.stringify(state.list))
    },
    //商品兑换数据存储
    showRecord(state,value){
      state.showrecord = value
      localStorage.setItem('showRecord',JSON.stringify(value))
    }
  },
  actions: {
  },
  modules: {
  }
})
